{extend name='admin@main'}

{block name="content"}

{include file='store@state/form_style'}
<script src="__ROOT__/extend/plugin/layui/extend/city-picker/city-picker.data.js"></script>
<link rel="stylesheet" type="text/css" href="__ROOT__/extend/plugin/layui/extend/city-picker/city-picker.css">


<form onsubmit="return false;" id="GoodsForm" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">

    <div class="layui-card-body think-box-shadow padding-left-40" >

        <div class="layui-form-item layui-row layui-col-space15" >

            <label class="layui-col-xs9 relative" style="width:30%">
                <span class="color-green">电站名称</span>
                <input name="name" required class="layui-input" placeholder="请输入电站名称" value="{$vo.name|default=''}">
            </label>
            <label class="layui-col-xs9 relative" style="width:30%">
                <span class="color-green">电站地址</span>
                <input name="address" required class="layui-input" placeholder="请输入电站地址" value="{$vo.address|default=''}">
            </label>

            <label class="layui-col-xs9 relative" style="width:30%">
                <span class="color-green">电站电话</span>
                <input name="phone" required class="layui-input" placeholder="请输入电站电话" value="{$vo.phone|default=''}">
            </label>

            <label class="layui-col-xs3 relative" style="width:30%">
                <span class="color-green">是否对外开放</span>
                <select style="width: 100%" name='is_open' required class='layui-select' lay-search>
                    {foreach [['id'=>'1','title'=>'开放'],['id'=>'0','title'=>'不开放']] as $cate}
                    {if isset($vo.is_open) and $vo.is_open eq $cate.id}
                    <option selected value="{$cate.id}">{$cate.title|default=''}</option>
                    {else}
                    <option value="{$cate.id}">{$cate.title|default=''}</option>
                    {/if}
                    {/foreach}
                </select>
            </label>

            <label class="layui-col-xs3 relative" style="width:30%">
                <span class="color-green">是否停车收费</span>
                <select style="width: 100%" name='is_charge' required class='layui-select' lay-search>
                    {foreach [['id'=>'1','title'=>'收费'],['id'=>'0','title'=>'不收费']] as $cate}
                    {if isset($vo.is_charge) and $vo.is_charge eq $cate.id}
                    <option selected value="{$cate.id}">{$cate.title|default=''}</option>
                    {else}
                    <option value="{$cate.id}">{$cate.title|default=''}</option>
                    {/if}
                    {/foreach}
                </select>
            </label>

            <label class="layui-col-xs3 relative" style="width:30%">
                <span class="color-green">充电速度</span>
                <select style="width: 100%" name='speed' required class='layui-select' lay-search>
                    {foreach [['id'=>'1','title'=>'快'],['id'=>'0','title'=>'慢']] as $cate}
                    {if isset($vo.speed) and $vo.speed eq $cate.title}
                    <option selected value="{$cate.title}">{$cate.title|default=''}</option>
                    {else}
                    <option value="{$cate.title}">{$cate.title|default=''}</option>
                    {/if}
                    {/foreach}
                </select>
            </label>



            <label class="layui-col-xs9 relative" style="width:30%">
                <span class="color-green">如何获取经纬度？</span>
                <a target="_blank" href="{:sysconf('relam_name')}/map.html"><input style="cursor: pointer" readonly type="button" class="layui-input" placeholder="打开高德地图" value="打开高德地图"></a>
            </label>

            <label class="layui-col-xs9 relative" style="width:30%">
                <span class="color-green">纬度</span>
                <input name="lat" required class="layui-input" placeholder="请输入纬度" value="{$vo.lat|default=''}">
            </label>

            <label class="layui-col-xs9 relative" style="width:30%">
                <span class="color-green">经度</span>
                <input name="lng" required class="layui-input" placeholder="请输入经度" value="{$vo.lng|default=''}">
            </label>


            <label class="layui-col-xs3 relative" style="width:30%">
                <span class="color-green">状态</span>
                <select style="width: 100%" name='status' required class='layui-select' lay-search>
                    {foreach [['id'=>'1','title'=>'正常'],['id'=>'2','title'=>'故障'],['id'=>'3','title'=>'被使用'],['id'=>'4','title'=>'停用']] as $cate}
                    {if isset($vo.status) and $vo.status eq $cate.title}
                    <option selected value="{$cate.id}">{$cate.title|default=''}</option>
                    {else}
                    <option value="{$cate.id}">{$cate.title|default=''}</option>
                    {/if}
                    {/foreach}
                </select>
            </label>

            <label class="layui-col-xs9 relative" style="width:30%">
                <span class="color-green">电站分佣比例(%)</span>
                <input name="station_rate" required   class="layui-input" placeholder="请输入电站分佣比例(%)" value="{$vo.station_rate|default='0'}">
            </label>

            <label class="layui-col-xs9 relative" style="width:30%">
                <span class="color-green">平台分佣比例(%)</span>
                <input name="platform_rate" required   class="layui-input" placeholder="请输入平台分佣比例(%)" value="{$vo.platform_rate|default='0'}">
            </label>

            <label class="layui-col-xs9 relative" style="width:30%">
                <span class="color-green">上级分佣比例(%)</span>
                <input name="parent_rate" required   class="layui-input" placeholder="请输入上级分佣比例(%)" value="{$vo.parent_rate|default='0'}">
            </label>



            <label class="layui-col-xs3 relative" style="width:30%">
                <span class="color-green">电站属性</span>
                <select style="width: 100%" name='type' required class='layui-select' lay-search>
                    {foreach [['id'=>'1','title'=>'物业'],['id'=>'2','title'=>'个人'],['id'=>'3','title'=>'联营电站'],['id'=>'4','title'=>'非联营电站']] as $cate}
                    {if isset($vo.type) and $vo.type eq $cate.id}
                    <option selected value="{$cate.id}">{$cate.title|default=''}</option>
                    {else}
                    <option value="{$cate.id}">{$cate.title|default=''}</option>
                    {/if}
                    {/foreach}
                </select>
            </label>

            <?php if($title=='添加'){ ?>
            <label class="layui-col-xs3 relative" style="width:30%">
                <span class="color-green">用户列表</span>
                <select style="width: 95%" name='user_id' required class='layui-select' lay-search>
                    <option  value="0">非联营电站</option>
                    {foreach $user_list as $cate}
                    {if isset($vo.user_id) and $vo.user_id eq $cate.id}
                    <option selected value="{$cate.id}">用户：{$cate.username|default=''},电话：{$cate.phone|default=''}</option>
                    {else}
                    <option value="{$cate.id}">用户：{$cate.username|default=''},电话：{$cate.phone|default=''}</option>
                    {/if}
                    {/foreach}
                </select>
            </label>
            <?php }else{ ?>
            <input type="hidden" name="user_id" value="{$vo['user_id']}">
            <?php }?>
        </div>

        <div class="layui-form-item">
            <span class="color-green label-required-prev">图片</span>
            <table class="layui-table">
                <thead>
                <tr>
                    <th class="text-left">图片</th>
                    <th class="text-left">营业执照</th>
                    <th class="text-left">展示图片</th>
                </tr>
                <tr>
                    <td width="90px" class="text-left"><input name="pic" type="hidden" value="{$vo.pic|default=''}"></td>
                    <td width="90px" class="text-left"><input name="license_image" type="hidden" value="{$vo.license_image|default=''}"></td>
                    <td width="auto" class="text-left"><input name="images" type="hidden" value="{$vo.images|default=''}"></td>
                </tr>
                </thead>
            </table>
            <script>$('[name="pic"]').uploadOneImage(),$('[name="license_image"]').uploadOneImage(), $('[name="images"]').uploadMultipleImage()</script>
        </div>

        <div class="layui-form-item layui-col-md8">
            <label class="layui-form-label" style="margin-left: 0;  padding: 0; text-align: left; line-height: 40px; color:#090;">选择地址：</label>
            <div class="layui-input-block">
                <input  type="text" autocomplete="on" class="layui-input" id="address" name="city-picker" readonly="readonly" data-toggle="city-picker" placeholder="请选择" value="{$vo.picker|default=''}">
            </div>
        </div>


        <div class="layui-form-item text-center">
            {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
            <button class="layui-btn layui-btn-danger" ng-click="hsitoryBack()" type="button">取消编辑</button>
            <button class="layui-btn" type="submit">保存</button>
        </div>

    </div>
</form>
{/block}

{block name='script'}
<script>
    window.form.render();

</script>

<!--<script type="text/javascript" src="__ROOT__/extend/plugin/layui/layui.all.js"></script>-->
<script type="text/javascript">
    layui.extend({
        //citypicker:'{/}./extend/plugin/layui/extend/city-picker/city-picker'
        citypicker:'__ROOT__'+'/extend/plugin/layui/extend/city-picker/city-picker'
    }).use(['jquery','citypicker','form'],function(){
        var $ = layui.$,
            form = layui.form,
            citypicker = layui.citypicker;

        var cityPicker = new citypicker("#address",{
            provincename:"provinceId",
            cityname:"cityId",
            districtname: "districtId",
            level: 'districtId',// 级别
        })


        //监听提交
        //        form.on('submit(citypickerDemo)',function(data){
        //            var address = $("#address").val(); console.log($("#provinceId").val());
        //            layer.open({
        //                type: 1,
        //                title: '地址信息',
        //                area: '400px;',
        //                shade: 0,
        //                content: '<div style="padding: 20px 20px;">'+ address +'</div>'
        //            });
        //            return false;
        //        })
    });

</script>
{/block}